home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  14.1 KB  |  467 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.1
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1985-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __RESOURCES__
  18. #define __RESOURCES__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25.     #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __FILES__
  29.     #include <Files.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55.  
  56. enum {
  57.     resSysHeap                    = 64,                            /*System or application heap?*/
  58.     resPurgeable                = 32,                            /*Purgeable resource?*/
  59.     resLocked                    = 16,                            /*Load it in locked?*/
  60.     resProtected                = 8,                            /*Protected?*/
  61.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  62.     resChanged                    = 2,                            /*Resource changed?*/
  63.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  64.     mapCompact                    = 64,                            /*Compact resource file*/
  65.     mapChanged                    = 32                            /*Write map out at update*/
  66. };
  67.  
  68. enum {
  69.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  70.     resSysHeapBit                = 6,                            /*In system/in application heap*/
  71.     resPurgeableBit                = 5,                            /*Purgeable/not purgeable*/
  72.     resLockedBit                = 4,                            /*Locked/not locked*/
  73.     resProtectedBit                = 3,                            /*Protected/not protected*/
  74.     resPreloadBit                = 2,                            /*Read in at OpenResource?*/
  75.     resChangedBit                = 1,                            /*Existing resource changed since last update*/
  76.     mapReadOnlyBit                = 7,                            /*is this file read-only?*/
  77.     mapCompactBit                = 6,                            /*Is a compact necessary?*/
  78.     mapChangedBit                = 5                                /*Is it necessary to write map?*/
  79. };
  80.  
  81. enum {
  82.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  83.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  84. };
  85.  
  86.  
  87. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  88. /*
  89.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  90.              and cannot be written in a high-level language without 
  91.              the help of mixed mode or assembly glue.
  92. */
  93. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                         ResErrUPP;
  94. #if OPAQUE_UPP_TYPES
  95.     EXTERN_API(ResErrUPP)
  96.     NewResErrUPP                   (ResErrProcPtr            userRoutine);
  97.  
  98.     EXTERN_API(void)
  99.     DisposeResErrUPP               (ResErrUPP                userUPP);
  100.  
  101.     EXTERN_API(void)
  102.     InvokeResErrUPP                   (OSErr                    thErr,
  103.                                     ResErrUPP                userUPP);
  104.  
  105. #else
  106.     enum { uppResErrProcInfo = 0x00001002 };                         /* register no_return_value Func(2_bytes:D0) */
  107.     #define NewResErrUPP(userRoutine)                                 (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  108.     #define DisposeResErrUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  109.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  110.     #pragma parameter InvokeResErrUPP(__D0, __A0)
  111.     void InvokeResErrUPP(OSErr thErr, ResErrUPP userUPP) = 0x4E90;
  112.     #else
  113.         #define InvokeResErrUPP(thErr, userUPP)                         CALL_ONE_PARAMETER_UPP((userUPP), uppResErrProcInfo, (thErr))
  114.     #endif
  115. #endif
  116. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  117. #define NewResErrProc(userRoutine)                                 NewResErrUPP(userRoutine)
  118. #define CallResErrProc(userRoutine, thErr)                        InvokeResErrUPP(thErr, userRoutine)
  119. #if !TARGET_OS_MAC
  120. /* QuickTime 3.0*/
  121. typedef CALLBACK_API( OSErr , ResourceEndianFilterPtr )(Handle theResource, Boolean currentlyNativeEndian);
  122. #endif  /* !TARGET_OS_MAC */
  123.  
  124. EXTERN_API( short )
  125. InitResources                    (void)                                                        ONEWORDINLINE(0xA995);
  126.  
  127. EXTERN_API( void )
  128. RsrcZoneInit                    (void)                                                        ONEWORDINLINE(0xA996);
  129.  
  130. EXTERN_API( void )
  131. CloseResFile                    (short                     refNum)                                ONEWORDINLINE(0xA99A);
  132.  
  133. EXTERN_API( OSErr )
  134. ResError                        (void)                                                        ONEWORDINLINE(0xA9AF);
  135.  
  136. EXTERN_API( short )
  137. CurResFile                        (void)                                                        ONEWORDINLINE(0xA994);
  138.  
  139. EXTERN_API( short )
  140. HomeResFile                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  141.  
  142. EXTERN_API( void )
  143. CreateResFile                    (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA9B1);
  144.  
  145. EXTERN_API( short )
  146. OpenResFile                        (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA997);
  147.  
  148. EXTERN_API( void )
  149. UseResFile                        (short                     refNum)                                ONEWORDINLINE(0xA998);
  150.  
  151. EXTERN_API( short )
  152. CountTypes                        (void)                                                        ONEWORDINLINE(0xA99E);
  153.  
  154. EXTERN_API( short )
  155. Count1Types                        (void)                                                        ONEWORDINLINE(0xA81C);
  156.  
  157. EXTERN_API( void )
  158. GetIndType                        (ResType *                theType,
  159.                                  short                     index)                                ONEWORDINLINE(0xA99F);
  160.  
  161. EXTERN_API( void )
  162. Get1IndType                        (ResType *                theType,
  163.                                  short                     index)                                ONEWORDINLINE(0xA80F);
  164.  
  165. EXTERN_API( void )
  166. SetResLoad                        (Boolean                 load)                                ONEWORDINLINE(0xA99B);
  167.  
  168. EXTERN_API( short )
  169. CountResources                    (ResType                 theType)                            ONEWORDINLINE(0xA99C);
  170.  
  171. EXTERN_API( short )
  172. Count1Resources                    (ResType                 theType)                            ONEWORDINLINE(0xA80D);
  173.  
  174. EXTERN_API( Handle )
  175. GetIndResource                    (ResType                 theType,
  176.                                  short                     index)                                ONEWORDINLINE(0xA99D);
  177.  
  178. EXTERN_API( Handle )
  179. Get1IndResource                    (ResType                 theType,
  180.                                  short                     index)                                ONEWORDINLINE(0xA80E);
  181.  
  182. EXTERN_API( Handle )
  183. GetResource                        (ResType                 theType,
  184.                                  short                     theID)                                ONEWORDINLINE(0xA9A0);
  185.  
  186. EXTERN_API( Handle )
  187. Get1Resource                    (ResType                 theType,
  188.                                  short                     theID)                                ONEWORDINLINE(0xA81F);
  189.  
  190. EXTERN_API( Handle )
  191. GetNamedResource                (ResType                 theType,
  192.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A1);
  193.  
  194. EXTERN_API( Handle )
  195. Get1NamedResource                (ResType                 theType,
  196.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA820);
  197.  
  198. #if TARGET_OS_MAC
  199.     #define MacLoadResource LoadResource
  200. #endif
  201. EXTERN_API( void )
  202. MacLoadResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  203.  
  204. EXTERN_API( void )
  205. ReleaseResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  206.  
  207. EXTERN_API( void )
  208. DetachResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  209.  
  210. EXTERN_API( short )
  211. UniqueID                        (ResType                 theType)                            ONEWORDINLINE(0xA9C1);
  212.  
  213. EXTERN_API( short )
  214. Unique1ID                        (ResType                 theType)                            ONEWORDINLINE(0xA810);
  215.  
  216. EXTERN_API( short )
  217. GetResAttrs                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  218.  
  219. EXTERN_API( void )
  220. GetResInfo                        (Handle                 theResource,
  221.                                  short *                theID,
  222.                                  ResType *                theType,
  223.                                  Str255                 name)                                ONEWORDINLINE(0xA9A8);
  224.  
  225. EXTERN_API( void )
  226. SetResInfo                        (Handle                 theResource,
  227.                                  short                     theID,
  228.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A9);
  229.  
  230. EXTERN_API( void )
  231. AddResource                        (Handle                 theData,
  232.                                  ResType                 theType,
  233.                                  short                     theID,
  234.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9AB);
  235.  
  236. EXTERN_API( long )
  237. GetResourceSizeOnDisk            (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  238.  
  239. EXTERN_API( long )
  240. GetMaxResourceSize                (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  241.  
  242. EXTERN_API( long )
  243. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  244.  
  245. EXTERN_API( void )
  246. SetResAttrs                        (Handle                 theResource,
  247.                                  short                     attrs)                                ONEWORDINLINE(0xA9A7);
  248.  
  249. EXTERN_API( void )
  250. ChangedResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  251.  
  252. EXTERN_API( void )
  253. RemoveResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  254.  
  255. EXTERN_API( void )
  256. UpdateResFile                    (short                     refNum)                                ONEWORDINLINE(0xA999);
  257.  
  258. EXTERN_API( void )
  259. WriteResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  260.  
  261. EXTERN_API( void )
  262. SetResPurge                        (Boolean                 install)                            ONEWORDINLINE(0xA993);
  263.  
  264. EXTERN_API( short )
  265. GetResFileAttrs                    (short                     refNum)                                ONEWORDINLINE(0xA9F6);
  266.  
  267. EXTERN_API( void )
  268. SetResFileAttrs                    (short                     refNum,
  269.                                  short                     attrs)                                ONEWORDINLINE(0xA9F7);
  270.  
  271. EXTERN_API( short )
  272. OpenRFPerm                        (ConstStr255Param         fileName,
  273.                                  short                     vRefNum,
  274.                                  SInt8                     permission)                            ONEWORDINLINE(0xA9C4);
  275.  
  276. EXTERN_API( Handle )
  277. RGetResource                    (ResType                 theType,
  278.                                  short                     theID)                                ONEWORDINLINE(0xA80C);
  279.  
  280. EXTERN_API( short )
  281. HOpenResFile                    (short                     vRefNum,
  282.                                  long                     dirID,
  283.                                  ConstStr255Param         fileName,
  284.                                  SInt8                     permission)                            ONEWORDINLINE(0xA81A);
  285.  
  286. EXTERN_API( void )
  287. HCreateResFile                    (short                     vRefNum,
  288.                                  long                     dirID,
  289.                                  ConstStr255Param         fileName)                            ONEWORDINLINE(0xA81B);
  290.  
  291. EXTERN_API( short )
  292. FSpOpenResFile                    (const FSSpec *            spec,
  293.                                  SignedByte             permission)                            TWOWORDINLINE(0x700D, 0xAA52);
  294.  
  295. EXTERN_API( void )
  296. FSpCreateResFile                (const FSSpec *            spec,
  297.                                  OSType                 creator,
  298.                                  OSType                 fileType,
  299.                                  ScriptCode             scriptTag)                            TWOWORDINLINE(0x700E, 0xAA52);
  300.  
  301. EXTERN_API( void )
  302. ReadPartialResource                (Handle                 theResource,
  303.                                  long                     offset,
  304.                                  void *                    buffer,
  305.                                  long                     count)                                TWOWORDINLINE(0x7001, 0xA822);
  306.  
  307. EXTERN_API( void )
  308. WritePartialResource            (Handle                 theResource,
  309.                                  long                     offset,
  310.                                  const void *            buffer,
  311.                                  long                     count)                                TWOWORDINLINE(0x7002, 0xA822);
  312.  
  313. EXTERN_API( void )
  314. SetResourceSize                    (Handle                 theResource,
  315.                                  long                     newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  316.  
  317. EXTERN_API( Handle )
  318. GetNextFOND                        (Handle                 fondHandle)                            TWOWORDINLINE(0x700A, 0xA822);
  319.  
  320.  
  321. #if !TARGET_OS_MAC
  322. /* QuickTime 3.0*/
  323. EXTERN_API_C( OSErr )
  324. RegisterResourceEndianFilter    (ResType                 theType,
  325.                                  ResourceEndianFilterPtr  theFilterProc);
  326.  
  327. #endif  /* !TARGET_OS_MAC */
  328.  
  329. /* Use TempInsertROMMap to force the ROM resource map to be
  330.    inserted into the chain in front of the system. Note that
  331.    this call is only temporary - the modified resource chain
  332.    is only used for the next call to the resource manager.
  333.    See IM IV 19 for more information. 
  334. */
  335. EXTERN_API( void )
  336. TempInsertROMMap                (Boolean                 tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  337.  
  338. /*
  339.   _________________________________________________________________________________________________________
  340.       
  341.    o RESOURCE CHAIN LOCATION - for use with the Resource Manager chain manipulation routines under Carbon.
  342.   _________________________________________________________________________________________________________
  343. */
  344.  
  345. typedef SInt16                             RsrcChainLocation;
  346. enum {
  347.     kRsrcChainBelowSystemMap    = 0,                            /* Below the system's resource map*/
  348.     kRsrcChainBelowApplicationMap = 1,                            /* Below the application's resource map*/
  349.     kRsrcChainAboveApplicationMap = 2                            /* Above the application's resource map*/
  350. };
  351.  
  352. /*
  353.    If the file is already in the resource chain, it is removed and re-inserted at the specified location
  354.    If the file has been detached, it is added to the resource chain at the specified location
  355.    Returns resFNotFound if it's not currently open.
  356. */
  357. EXTERN_API( OSErr )
  358. InsertResourceFile                (SInt16                 refNum,
  359.                                  RsrcChainLocation         where);
  360.  
  361. /*
  362.    If the file is not currently in the resource chain, this returns resNotFound
  363.    Otherwise, the resource file is removed from the resource chain.
  364. */
  365. EXTERN_API( OSErr )
  366. DetachResourceFile                (SInt16                 refNum);
  367.  
  368. /*
  369.    Returns true if the resource file is already open and known by the Resource Manager (i.e., it is
  370.    either in the current resource chain or it's a detached resource file.)  If it's in the resource 
  371.    chain, the inChain Boolean is set to true on exit and true is returned.  If it's an open file, but
  372.    the file is currently detached, inChain is set to false and true is returned.  If the file is open,
  373.    the refNum to the file is returned.
  374. */
  375. EXTERN_API( Boolean )
  376. FSpResourceFileAlreadyOpen        (const FSSpec *            resourceFile,
  377.                                  Boolean *                inChain,
  378.                                  SInt16 *                refNum)                                TWOWORDINLINE(0x7010, 0xA822);
  379.  
  380. /*
  381.    FSpOpenOrphanResFile should be used to open a resource file that is persistent across all contexts,
  382.    because using OpenResFile normally loads a map and all preloaded resources into the application
  383.    context.  FSpOpenOrphanResFile loads everything into the system context and detaches the file 
  384.    from the context in which it was opened.  If the file is already in the resource chain and a new
  385.    instance is not opened, FSpOpenOrphanResFile will return a paramErr.
  386.    Use with care, as can and will fail if the map is very large or a lot of preload
  387.    resources exist.
  388. */
  389. EXTERN_API( OSErr )
  390. FSpOpenOrphanResFile            (const FSSpec *            spec,
  391.                                  SignedByte             permission,
  392.                                  SInt16 *                refNum);
  393.  
  394.  
  395. EXTERN_API_C( Handle )
  396. getnamedresource                (ResType                 theType,
  397.                                  const char *            name);
  398.  
  399. EXTERN_API_C( Handle )
  400. get1namedresource                (ResType                 theType,
  401.                                  const char *            name);
  402.  
  403. EXTERN_API_C( short )
  404. openrfperm                        (const char *            fileName,
  405.                                  short                     vRefNum,
  406.                                  char                     permission);
  407.  
  408. EXTERN_API_C( short )
  409. openresfile                        (const char *            fileName);
  410.  
  411. EXTERN_API_C( void )
  412. createresfile                    (const char *            fileName);
  413.  
  414. EXTERN_API_C( void )
  415. getresinfo                        (Handle                 theResource,
  416.                                  short *                theID,
  417.                                  ResType *                theType,
  418.                                  char *                    name);
  419.  
  420. EXTERN_API_C( void )
  421. setresinfo                        (Handle                 theResource,
  422.                                  short                     theID,
  423.                                  const char *            name);
  424.  
  425. EXTERN_API_C( void )
  426. addresource                        (Handle                 theResource,
  427.                                  ResType                 theType,
  428.                                  short                     theID,
  429.                                  const char *            name);
  430.  
  431. #if OLDROUTINENAMES
  432. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  433. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  434. #define RmveResource(theResource) RemoveResource(theResource)
  435. #endif  /* OLDROUTINENAMES */
  436.  
  437. /*
  438.     These typedefs were originally created for the Copland Resource Mangager
  439. */
  440. typedef short                             ResFileRefNum;
  441. typedef short                             ResID;
  442. typedef short                             ResAttributes;
  443. typedef short                             ResFileAttributes;
  444.  
  445.  
  446.  
  447. #if PRAGMA_STRUCT_ALIGN
  448.     #pragma options align=reset
  449. #elif PRAGMA_STRUCT_PACKPUSH
  450.     #pragma pack(pop)
  451. #elif PRAGMA_STRUCT_PACK
  452.     #pragma pack()
  453. #endif
  454.  
  455. #ifdef PRAGMA_IMPORT_OFF
  456. #pragma import off
  457. #elif PRAGMA_IMPORT
  458. #pragma import reset
  459. #endif
  460.  
  461. #ifdef __cplusplus
  462. }
  463. #endif
  464.  
  465. #endif /* __RESOURCES__ */
  466.  
  467.